<!DOCTYPE html>
<!-- now.html -->
<html>
<head>
<meta charset="utf8" />
<title>时钟</title>
<!-- 外部导入 -->
<link rel="stylesheet" href="" type="text/css">
<!-- 内部样式 -->
<style type="text/css">
#time {
	width: 300px;
	height: 100px;
	background-color: yellow;
	color: red;
	font-size: 50px;
}
</style>
<!-- 嵌入使用 -->
<script type="text/javascript">
	function clock() {
		var now = new Date();// 取得浏览器的当前时间
		var hour = now.getHours();
		var minute = now.getMinutes();
		var second = now.getSeconds();
		if (hour < 10)
			hour = "0" + hour;
		if (minute < 10)
			minute = "0" + minute;
		if (second < 10)
			second = "0" + second;
		var str = hour + ":" + minute + ":" + second;
		var time = document.getElementById("time");
		time.innerText = str;
		setTimeout("clock()", 1000);
	}
</script>
<!-- 引入使用 -->
<script type="text/javascript" src="1.js"> </script>
</head>
<body onload="clock()">
	
	<div id="time">这里显示时间</div>
</body>
</html>